﻿using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using WebKit;

namespace NewBrower
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            AutoScroll = true;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
//            WebKit.WebKitBrowser brower = new WebKitBrowser();
//            brower.Dock = DockStyle.Fill;
//            this.Controls.Add(brower);
//            brower.Navigate("http://www.baidu.com");
              webKitBrowser1.Navigate("http://ie.icoa.cn/");//该链接可以检测浏览器内核版本

        }

        private void GoBtn_Click(object sender, EventArgs e)
        {
            webKitBrowser1.Navigate(textBox1.Text);
        }

        //双屏铺满
        private void showOnMonitor()
        {
            Screen[] sc;
            sc = Screen.AllScreens;
            if(sc.Length<=1)
                return;
            //this.FormBorderStyle = FormBorderStyle.None; //无边框全屏显示
            this.StartPosition = FormStartPosition.Manual;
            this.Location = new Point(sc[0].Bounds.Left, sc[0].Bounds.Top);
            this.Width = sc[0].Bounds.Width + sc[1].Bounds.Width;
            this.Height = sc[0].Bounds.Height;
            //this.WindowState = FormWindowState.Maximized;//最大化窗口
            this.WindowState = FormWindowState.Normal;
        
        }

        private void FillBtn_Click(object sender, EventArgs e)
        {
            showOnMonitor();
        }

        private void Form1_SizeChanged(object sender, EventArgs e)
        {
            panel1.Width = this.Width;
            panel1.Height = this.Height;
            webKitBrowser1.Dock = DockStyle.Fill;
        }


        //加载debug文件夹下exe文件
//        private void RunBtn_Click(object sender, EventArgs e)
//        {
//            Process mayProcess = null;
//            try
//            {
//                mayProcess = new Process();
//                string fileName = @"";
//                ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(fileName)
//                {
//                    UseShellExecute = true,
//                    CreateNoWindow = true,
//                    WindowStyle = ProcessWindowStyle.Normal
//                };
//                mayProcess.StartInfo = myProcessStartInfo;
//                mayProcess.Start();
//                mayProcess.WaitForExit();
//            }
//            catch (Exception ex)
//            {
//                Console.WriteLine("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString());
//            }
//    }
    }
}
